﻿@inject NetCoreCMS.IServices.ISite_paymentService _site_payment
@{
    Layout = null;
    Sysconfig config = ViewData["config"] as Sysconfig;
    string action = ViewBag.action as string;
    List<User_recharge> rechargeList = ViewBag.rechargeList as List<User_recharge>;
    List<User_amount_log> amountList = ViewBag.amountList as List<User_amount_log>;
    Users userModel = ViewBag.userModel as Users;
}
<!DOCTYPE html>
<!--HTML5 doctype-->
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>账户余额</title>
    <link rel="stylesheet" type="text/css" href="/mobile/css/style.css" />
    <script type="text/javascript" charset="utf-8" src="/mobile/js/zepto.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/mobile/js/weui.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/mobile/js/common.js"></script>
</head>

<body ontouchstart>
    <div class="page">
        <!--页面头部-->
        <div class="header">
            <a class="back" href="javascript:history.back();">
                <i class="iconfont icon-arrow-left"></i>
            </a>
            <h3>账户余额</h3>
            <div class="right">
                <a class="weui-cell_access weui-cell_link" asp-area="Web" asp-controller="Usercenter" asp-action="Index" asp-route-act="index">
                    <i class="iconfont icon-user"></i>
                </a>
            </div>
        </div>
        <!--/页面头部-->

        <div class="page__bd">

            @if(action=="recharge")
            {
            <!--账户充值-->
            <link rel="stylesheet" type="text/css" href="/mobile/css/validate.css" />
            <script type="text/javascript" charset="utf-8" src="/mobile/js/mvalidate.js"></script>
            <script type="text/javascript" charset="utf-8" src="/mobile/js/mvalidate-extend.js"></script>
            <script type="text/javascript">
                $(function () {
                    //初始化表单
                    AjaxInitForm('#rechargeForm', '#btnSubmit', 0);
                    //选中TAB样式
                    $(".weui-tabbar a").eq(1).addClass("weui-bar__item_on");
                });
            </script>
            <form id="rechargeForm" name="rechargeForm" class="form-box" url="/submit_ajax?action=user_amount_recharge">
                <div class="weui-form-preview" style="margin-top:10px;">
                    <div class="weui-form-preview__hd">
                        <div class="weui-form-preview__item">
                            <label class="weui-form-preview__label">当前余额</label>
                            <em class="weui-form-preview__value">¥@userModel.amount</em>
                        </div>
                    </div>
                </div>

                <div class="weui-panel weui-panel_access">
                    <div class="weui-panel__hd">账户充值</div>
                    <div class="weui-panel__bd">
                        <div class="weui-cells_form form-box">
                            <div class="weui-cell">
                                <div class="weui-cell__hd">
                                    <label class="weui-label">充值金额</label>
                                </div>
                                <div class="weui-cell__bd">
                                    <input id="order_amount" name="order_amount" type="text" class="weui-input" placeholder="请输入金额" data-validate="n" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="weui-panel weui-panel_access">
                    <div class="weui-panel__hd">支付方式</div>
                    <div class="weui-panel__bd">
                        <div class="weui-cells_radio form-box">
                            <!--取得一个DataTable-->
                            @{ var payList = _site_payment.GetList("P.type=1 and S.payment_id=5");}
                            @foreach(Payment dr in payList)
                            {
                            <label class="weui-cell weui-check__label" for="p-@dr.id">
                                <div class="weui-cell__bd">
                                    <p>@dr.title</p>
                                </div>
                                <div class="weui-cell__ft">
                                    <input id="p-@dr.id" name="payment_id" type="radio" class="weui-check" value="@dr.id" data-validate="select" />
                                    <span class="weui-icon-checked"></span>
                                </div>
                            </label>
                            }
                        </div>
                    </div>
                </div>

                <div class="weui-btn-area">
                    <input id="btnSubmit" name="btnSubmit" type="submit" class="weui-btn weui-btn_primary" value="确认充值" />
                </div>
            </form>
            <!--账户充值-->
            }
            else if(action=="log")
            {
            <!--充值记录-->
            <script type="text/javascript">
                $(function () {
                    //选中TAB样式
                    $(".weui-tabbar a").eq(2).addClass("weui-bar__item_on");
                });
                //删除方法
                function ExecPostBack(checkValue) {
                    if (arguments.length == 1) {
                        ExecDelete('/submit_ajax?action=user_recharge_delete', checkValue, '#turl');
                    } else {
                        var valueArr = '';
                        $("input[name='checkId']:checked").each(function (i) {
                            valueArr += $(this).val();
                            if (i < $("input[name='checkId']:checked").length - 1) {
                                valueArr += ","
                            }
                        });
                        ExecDelete('/submit_ajax?action=user_recharge_delete', valueArr, '#turl');
                    }
                }
            </script>

            <div class="detail-list">
                <ul>                   
                    <!--取得分页页码列表-->
                    @foreach(User_recharge dr in rechargeList)
                    {
                    <li>
                        <div class="detail-hd">
                            <span class="fr">
                                @if (dr.status > 0)
                                {
                                @:已完成
                                }
                                else
                                {
                                @:未完成
                                }
                            </span>
                            <span>@dr.add_time</span>
                        </div>
                        <div class="detail-bd">
                            <div class="list-box">
                                <div class="txt-box">
                                    <h2>订单号 @dr.recharge_no</h2>
                                    <p class="note">
                                        <span class="fr">
                                            ￥@dr.amount
                                        </span>
                                        <span>@dr.payment_id</span>
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="detail-ft">
                            <div class="ft-btn">
                                <div class="btn-box">
                                    <a href="javascript:;" onclick="ExecPostBack('@dr.id');">
                                        <i class="iconfont icon-delete"></i>
                                        删除
                                    </a>
                                </div>
                            </div>
                        </div>
                    </li>
                    }
                    @if(rechargeList.Count==0)
                    {
                    <div class="nodata">暂无记录...</div>
                    }
                </ul>
            </div>

            <!--分页页码-->
            <div class="page-list">
                @Html.Raw(ViewBag.pagelist)
            </div>
            <!--/分页页码-->

        <input id="turl" type="hidden" value="/Web/Useramount/Index?action=log" /><!--存在跳转的URL值-->
            <!--/充值记录-->
            }
            else if(action=="list")
            {
            <!--收支明细-->
            <script type="text/javascript">
                $(function () {
                    //选中TAB样式
                    $(".weui-tabbar a").eq(3).addClass("weui-bar__item_on");
                });
                //删除方法
                function ExecPostBack(checkValue) {
                    if (arguments.length == 1) {
                        ExecDelete('/submit_ajax?action=user_amount_delete', checkValue, '#turl');
                    } else {
                        var valueArr = '';
                        $("input[name='checkId']:checked").each(function (i) {
                            valueArr += $(this).val();
                            if (i < $("input[name='checkId']:checked").length - 1) {
                                valueArr += ","
                            }
                        });
                        ExecDelete('/submit_ajax?action=user_amount_delete', valueArr, '#turl');
                    }
                }
            </script>

            <div class="detail-list">
                <ul>
                    <!--取得分页页码列表-->
                    @foreach(User_amount_log dr in amountList)
                    {
                    <li>
                        <div class="detail-bd">
                            <div class="list-box">
                                <div class="txt-box">
                                    <h2>@dr.remark</h2>
                                    <p class="note">
                                        <span class="fr">
                                            @if (dr.value > 0)
                                            {
                                            @("+" + dr.value)
                                            }
                                            else
                                            {
                                            @dr.value
                                            }
                                        </span>
                                        <span>@dr.add_time</span>
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="detail-ft">
                            <div class="ft-btn">
                                <div class="btn-box">
                                    <a href="javascript:;" onclick="ExecPostBack('@dr.id');">
                                        <i class="iconfont icon-delete"></i>
                                        删除
                                    </a>
                                </div>
                            </div>
                        </div>
                    </li>
                    }
                    @if(amountList.Count==0)
                    {
                    <div class="nodata">暂无记录...</div>
                    }
                </ul>
            </div>

            <!--分页页码-->
            <div class="page-list">
                @Html.Raw(ViewBag.pagelist)
            </div>
            <!--/分页页码-->

            <input id="turl" type="hidden" value="/Web/Useramount/Index?action=list" /><!--存在跳转的URL值-->
            <!--/收支明细-->
            }

        </div>

        <!--版权信息-->
        @await Html.PartialAsync("~/Areas/Web/Views/Shared/_Copyright.cshtml")
        <!--/版权信息-->
        <!--底部导航-->
        <div class="weui-tab foot-nav">
            <div class="weui-tab__panel">

            </div>
            <div class="weui-tabbar">
                <a asp-area="Web" asp-controller="Index" asp-action="Index" class="weui-tabbar__item">
                    <i class="iconfont icon-home weui-tabbar__icon"></i>
                    <p class="weui-tabbar__label">首页</p>
                </a>
                <a asp-area="Web" asp-controller="Useramount" asp-action="Index" asp-route-act="recharge" class="weui-tabbar__item">
                    <i class="iconfont icon-money weui-tabbar__icon"></i>
                    <p class="weui-tabbar__label">账户充值</p>
                </a>
                <a asp-area="Web" asp-controller="Useramount" asp-action="Index" asp-route-act="log" class="weui-tabbar__item">
                    <i class="iconfont icon-amount weui-tabbar__icon"></i>
                    <p class="weui-tabbar__label">充值记录</p>
                </a>
                <a asp-area="Web" asp-controller="Useramount" asp-action="Index" asp-route-act="list" class="weui-tabbar__item">
                    <i class="iconfont icon-log weui-tabbar__icon"></i>
                    <p class="weui-tabbar__label">收支明细</p>
                </a>
            </div>
        </div>
        <!--/底部导航-->
    </div>
</body>
</html>
